<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3>留言板</h3>
    <input type="text" id="inp">
    <button onclick="fun()">提交</button>
    <ul >

    </ul>
</body>
<script>
    var sj=new Date(),a=sj.getFullYear(),a1=sj.getMonth()+1,a2=sj.getDate(),a3=Date().slice(15,25),
         ww = a+a1+a3
    function show(){
         var res=localStorage.getItem('asdf')??''
        if(JSON.parse(res)){
            res=JSON.parse(res)
            var str = ''
            for(i in res){
                str += `<li>内容 : ${res[i].内容}  —— 时间${ww}</li>`
            }
            document.getElementsByTagName('ul')[0].innerHTML=str
        }
    }
    function fun(){
        if(localStorage.getItem('asdf')==null){
            localStorage.asdf=JSON.stringify([])
        }
        var qwe = document.getElementById('inp').value
        var data = JSON.parse(localStorage.getItem('asdf'))
        data.unshift({内容:qwe})
        data=JSON.stringify(data)
        localStorage.setItem('asdf',data)
        show()
    }
</script>
</html>